package Z11_12_customizedPool;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

/**
 * @author： pang-yun
 * @date： 2021-11-20 13:48
 * 功能目的 ：用于 shutDown
 */
@Slf4j
public class ShutDown {
    public static void main(String[] args) throws InterruptedException {
        ExecutorService pool = Executors.newFixedThreadPool(2);

        Future<?> submit = pool.submit(() -> {
            TimeUnit.SECONDS.sleep(1);
            log.info("{}","A");
        return "A";});

        Future<?> submit2 = pool.submit(() -> {
            TimeUnit.SECONDS.sleep(1);
            log.info("{}","B");
            return "A";});
        Future<?> submit3 = pool.submit(() -> {
            TimeUnit.SECONDS.sleep(1);
            log.info("{}","C");
            return "A";});


        log.info("shutdown");
        pool.shutdown();
        // 阻塞其他任务执行
//        pool.awaitTermination(3,TimeUnit.SECONDS);
        log.info("ShutDownAfter");

    }
}
